<?php

namespace addons\sum\controller\agent;

use addons\shopro\exception\ShoproException;
use addons\sum\controller\Common;
use addons\sum\exception\SumException;
use addons\sum\service\agent\Agent as AgentService;
use think\Db;
use think\exception\HttpResponseException;

class Apply extends Common
{

    protected $noNeedLogin = [];
    protected $noNeedRight = ['*'];

    // 发起申请请求
    public function apply()
    {
        $user = auth_user();
        $params = $this->request->only([
            'user_name', 'phone', 'image_sfzrx', 'image_sfzgh', 'province_name', 'city_name', 'district_name'
        ]);
        $this->svalidate($params, ".apply");
        $store_service=new AgentService($user);
        try {
            $res=$store_service->apply($params);
        } catch (SumException $e) {
            $this->error($e->getMessage());
        }

        $this->success('申请成功');
    }
}
